# -*- coding:utf-8 -*-
"""
该脚本执行导出文件功能
"""
try:
    import maya.cmds as cmds
    import maya.mel as mel
except Exception as test_ERR:
    print('test')




def exportFBX(fbx_path):
    """
    导出fbx
    :param fbx_path:
    :return:
    """
    choose = cmds.confirmDialog(title='Export FBX', message=u'选择导出方式', icon='question',
                                button=[u'导出所选择物体', u'导出全部场景', u'取消'], defaultButton=u'导出全部场景', cancelButton='取消')
    fbx_export = ''
    if choose == u'导出所选择物体':
        fbx_export = 'FBXExport -f "{}" -s'.format(fbx_path)

    elif choose == u'导出全部场景':
        fbx_export = 'FBXExport -f "{}" '.format(fbx_path)

    else:
        pass
    if fbx_export:
        mel.eval(fbx_export)
        cmds.confirmDialog(title=u'提示', message=u'输出FBX至\n{}'.format(fbx_path), button=['Yes'], defaultButton='Yes',
                           dismissString='No')


def exportABC(abc_path):
    """
    导出abc
    :param abc_path:
    :return:
    """
    choose = cmds.confirmDialog(title='Export ABC', message=u'选择导出方式', icon='question',
                                button=[u'导出所选择物体', u'导出全部场景', u'取消'], defaultButton=u'导出全部场景', cancelButton='取消')
    abc_export = ''
    start_frame = cmds.playbackOptions(q=1, minTime=True)
    end_frame = cmds.playbackOptions(q=1, maxTime=True)
    if choose == u'导出所选择物体':
        objs = cmds.ls(sl=1,l=1)
        if objs:
            c_objs = ' '.join(objs)
            abc_export = 'AbcExport -j "-frameRange {} {} -rt {} -ro -uvWrite -file {}"'.format(int(start_frame),int(end_frame),c_objs,abc_path)
        else:
            cmds.confirmDialog(title=u'提示', message=u'请先选择物体', button=['Yes'], defaultButton='Yes',
                               dismissString='No')

    elif choose == u'导出全部场景':
        abc_export = 'AbcExport -j "-frameRange {} {}  -ro -uvWrite -file {}"'.format(int(start_frame),int(end_frame),abc_path)

    else:
        pass

    if abc_export:
        mel.eval(abc_export)
        cmds.confirmDialog(title=u'提示', message=u'输出ABC至\n{}'.format(abc_path), button=['Yes'], defaultButton='Yes',
                           dismissString='No')











